//
//  MovieScoreViewController.m
//  product_B
//
//  Created by lanou on 16/6/12.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "MovieScoreViewController.h"
#import "Star.h"
@interface MovieScoreViewController ()<UITextViewDelegate>
@property (nonatomic,strong)Star *star;
@property (nonatomic,strong)UITextView *textView;
@property (nonatomic,strong)UILabel *smallLabel;
@end

@implementation MovieScoreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationItem.title = @"短评";
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(kWidth * 0.3 - 60, kHeight * 0.1 , 60, 50)];
    label.text = @"评分";
    label.font = [UIFont systemFontOfSize:25];
    [self.view addSubview:label];
    _star = [[Star alloc]initWithFrame:CGRectMake(kWidth * 0.3, kHeight * 0.1, kWidth * 0.55, 50)];
    _star.show_star = 0;
    _star.font_size = 40;
    _star.isSelect = YES;
    [self.view addSubview:_star];
    _textView = [[UITextView alloc]initWithFrame:CGRectMake(kWidth * 0.3 - 60, kHeight * 0.2, kWidth * 0.55 + 60, kHeight * 0.4)];
    _textView.delegate = self;
    _textView.font = [UIFont systemFontOfSize:20];
    [self.view addSubview:_textView];
    _smallLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 5, 200, 30)];
    _smallLabel.textColor = [UIColor grayColor];
    _smallLabel.text = @"在这里写下你想说的...";
    [_textView addSubview:_smallLabel];
    UIBarButtonItem *rightButton = [[UIBarButtonItem alloc]initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(barButtonItemAction:)];
    self.navigationItem.rightBarButtonItem  =rightButton;
}
- (void)barButtonItemAction:(UIBarButtonItem *)sender{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:[NSString stringWithFormat:@"您的评分:%ld",_star.show_star] preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"提交" style:UIAlertActionStyleDefault handler:nil];
    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDestructive handler:nil];
    
    [alert addAction:action1];
    [alert addAction:action];
    [self presentViewController:alert animated:YES completion:nil];
}
-(void)textViewDidChange:(UITextView *)textView
{
    
    if (_textView.text.length == 0) {
        _smallLabel.text = @"在这里写下你想说的...";
    }else{
        _smallLabel.text = @"";
    }
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [super touchesBegan:touches withEvent:event];
    [self.view endEditing:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
